<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=8">
    <title>左边导航</title>
    <link rel="stylesheet" type="text/css" href="../../static/left/reset.css"/>
    <link rel="stylesheet" type="text/css" href="../../static/left/common.css"/>
    {#    <script type="text/javascript" src="../../static/js/jquery-1.12.3.js"></script>#}
    <!--框架高度设置-->
    <script type="text/javascript">
        $(function () {
            $('.sidenav li').click(function () {
                $(this).siblings('li').removeClass('now');
                $(this).addClass('now');
            });

            $('.erji li').click(function () {
                $(this).siblings('li').removeClass('now_li');
                $(this).addClass('now_li');
            });

            var main_h = $(window).height();
            $('.sidenav').css('height', main_h + 'px');
        })
    </script>
    <!--框架高度设置-->
</head>

<body>
<div id="left_ctn" >
    <ul class="sidenav" >
        <li class="left_item" >
            <div class="nav_m">
                <span><a>门店管理</a></span>
                <i>&nbsp;</i>
            </div>
            <ul class="erji">
                <li>
                    <a class="abcd_href" data-url="/admin/store/list.html" target="main">门店列表</a>
                </li>
                <li>
                    <a class="abcd_href" data-url="/admin/store/newly.html" target="main">新增门店</a>
                </li>
{#                <li>#}
{#                    <a class="abcd_href" data-url="/admin/machine/newly.html" target="main">新增机器</a>#}
{#                </li>#}
                <li>
                    <a class="abcd_href" data-url="/admin/recharge/list.html" target="main">充值卡列表</a>
                </li>
                <li>
                    <a class="abcd_href" data-url="/admin/model/list.html" target="main">模式列表</a>
                </li>

            </ul>
        </li>
        <li class="left_item" >
            <div class="nav_m">
                <span><a>支付管理</a></span>
                <i>&nbsp;</i>
            </div>
            <ul class="erji">
                <li>
                    <a class="abcd_href" data-url="/admin/order_list.html" target="main">订单列表</a>
                </li>
                <li>
                    <a class="abcd_href" data-url="/admin/data_total.html" target="main">数据汇总</a>
                </li>

            </ul>
        </li>
        <li class="left_item" >
            <div class="nav_m">
                <span><a>洗车管理</a></span>
                <i>&nbsp;</i>
            </div>
            <ul class="erji">
                <li>
                    <a class="abcd_href" data-url="/admin/user_wash_list.html" target="main">洗车记录列表</a>
                </li>

            </ul>
        </li>
        <li class="left_item" >
            <div class="nav_m">
                <span><a>会员管理</a></span>
                <i>&nbsp;</i>
            </div>
            <ul class="erji">
                <li>
                    <a class="abcd_href" data-url="/admin/user_list.html" target="main">会员列表</a>
                </li>

            </ul>
        </li>
        <li class="left_item" >
            <div class="nav_m">
                <span><a>商家管理</a></span>
                <i>&nbsp;</i>
            </div>
            <ul class="erji">
                <li>
                    <a class="abcd_href" data-url="/admin/business_list.html" target="main">商家列表</a>
                </li>

                <li>
                    <a class="abcd_href" data-url="/admin/give_list.html" target="main">商家赠送记录</a>
                </li>
                <li>
                    <a class="abcd_href" data-url="/admin/pay/log.html" target="main">商家购买列表</a>
                </li>
                <li>
                    <a class="abcd_href" data-url="/admin/business/recharge.html" target="main">商家充值列表</a>
                </li>
                 <li>
                    <a class="abcd_href" data-url="/admin/business/suit.html" target="main">商家套餐列表</a>
                </li>

            </ul>
        </li>

        <li class="left_item" >
            <div class="nav_m">
                <span><a>系统设置</a></span>
                <i>&nbsp;</i>
            </div>
            <ul class="erji">
                <li>
                    <a class="abcd_href" data-url="/admin/list.html" target="main">管理员列表</a>
                </li>

                <li>
                    <a class="abcd_href_" id="logout" href="/admin/logout">退出系统</a>
                </li>
            </ul>
        </li>
    </ul>
</div>
<script>
    function left() {
        var c_index = getCookie("abcd");
        $.each($(".abcd_href"), function (index, t) {
            if (index == c_index) {
                $(".now").removeClass("now");
                $(".now_li").removeClass("now_li");
                $(this).parent().addClass("now_li");
                $(this).parent().parent().parent().addClass("now");
            }
        });
    }

    $(function () {
        left()
    });

    $(".abcd_href").click(function () {
        var tmp = $(this).attr("data-url");
        $.each($(".abcd_href"), function (index, t) {
            if (tmp == $(t).attr("data-url")) {
                setCookie("abcd", index);
            }
        });
        location.href = tmp;
    });

    function setCookie(name, value) {
        var Days = 30;
        var exp = new Date();
        exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
        document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString() + ";path=/";
    }

    function getCookie(name) {
        var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");

        if (arr = document.cookie.match(reg))

            return unescape(arr[2]);
        else
            return null;
    }

    $(document).ready(function () {
        $.ajax({
            url: '/admin/jurisdiction',
            type: 'GET',
            success: function (data) {
                $('.left_item .erji li a').each(function () {
                    $(this).parent().hide();
                    $(this).parent().parent().parent().hide();
                })
                if (data.status == 'success') {
                    $.each(data.arr, function (index2, la2) {
                        $('.left_item .erji li a').each(function () {
                            if ($(this).text() === la2.route_name) {
                                $(this).parent().parent().parent().show();
                                $(this).parent().show(10);
                            }
                        });
                    });
                } else if (data.status == 'all') {
                    $('.left_item .erji li a').each(function () {
                        $(this).parent().show();
                        $(this).parent().parent().parent().show();
                    })
                }
            }
        })
    })
</script>
</body>
</html>
